package com.ruoyi.initialdata.tool;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;

import java.util.ArrayList;
import java.util.List;

public class CreateXml {
    public static void main(String[] args) {
        List<Data> dataList = generateDataList();
        for (Data data : dataList) {
            System.out.println(data);
        }
    }

    public static List<Data> generateDataList() {
        List<Data> dataList = new ArrayList<>();

        /*String[] indexNames = {
                "人口和经济情况", "人均 GDP", "地区生产总值", "人口数量", "物价水平",
                "平均收入", "基尼系数", "贫困率", "劳动情况", "劳动力参与率",
                "就业率", "城市人口增长率", "人口自然增长率", "出生率", "死亡率",
                "人口迁移情况", "迁入率", "迁出率", "人口密度", "城市发展情况",
                "城市面积", "建设用地面积", "绿地覆盖率", "交通拥堵程度", "车流量",
                "车辆行驶速度", "延误时间", "总路段饱和度", "空间占有率", "二氧化碳排放量",
                "公共交通设施", "道路占地面积", "交通设备占地面积", "公共交通设施覆盖范围", "自然环境保护状况",
                "空气质量", "水质状况", "土地利用率", "土地覆盖情况", "生物多样性",
                "温室气体排放情况", "垃圾处理情况", "垃圾堆放面积", "垃圾填埋覆盖区域", "垃圾分类率",
                "垃圾处理量成本投入", "污水处理情况", "污水处理率", "河流水质", "污水处理成本投入",
                "城市文化教育", "文化活动情况", "文化活动数量", "文化活动性质", "文化活动参与人数",
                "文化活动覆盖面", "教育情况", "教育设施数量", "校舍建设数量", "小学建筑数量",
                "中学建筑数量", "大学建筑数量", "设备设施数量", "教师建设", "教师教育背景",
                "教师教学经验", "师生比例", "学生情况", "升学率", "初升高升学率",
                "高考一本率", "医疗服务情况", "医疗服务覆盖范围", "医疗服务质量", "患者满意度",
                "医疗安全", "手术感染率", "药物误食率", "医疗效果", "治愈率",
                "康复率", "再住院率", "时间效率", "城市商业和住宅发展", "商业设施情况",
                "商业设施种类", "商业设施数量", "住房价值", "房屋成交率", "房屋总数",
                "房屋成交量", "房屋平均价格", "房屋平均房龄", "企业发展情况", "企业数量",
                "注册企业数量", "在营企业数量", "新增企业数量", "破产企业数量",
                "企业规模", "生产总值", "净利润"
        };*/

        String[] indexNames = {
                "医疗收入总额", "门诊收入", "住院收入", "急诊收入", "手术收入", "检验收入", "检查收入",
                "药品收入", "耗材收入", "医疗保险收入", "自费收入", "医疗支出总额", "人员工资支出",
                "药品采购支出", "耗材采购支出", "设备采购支出", "医疗器械采购支出", "房屋租赁支出",
                "设备维护支出", "医疗技术支出"
        };

        Random random = new Random();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        for (int i = 1; i <= 50; i++) {
            Data data = new Data();
            data.setDataId(i);
            data.setDataIndexName(indexNames[random.nextInt(indexNames.length)]);
            if (random.nextBoolean()) {
                data.setDataType("字符串");
                data.setDataNumber("");
                data.setDataString("人口经济");
            } else {
                data.setDataType("数字");
                data.setDataNumber(String.valueOf(100 * random.nextInt(indexNames.length)));
                data.setDataString("");
            }
            data.setDataTime(generateRandomDate().format(formatter));
            data.setDataContent("测试" + data.dataType + String.valueOf(5 * random.nextInt(indexNames.length)));
            dataList.add(data);
        }


        return dataList;
    }

    public static LocalDate generateRandomDate() {
        Random random = new Random();
        int minDay = (int) LocalDate.of(2020, 1, 1).toEpochDay();
        int maxDay = (int) LocalDate.of(2024, 12, 31).toEpochDay();
        int randomDay = minDay + random.nextInt(maxDay - minDay);
        return LocalDate.ofEpochDay(randomDay);
    }

    static class Data {
        private int dataId;
        private String dataIndexName;
        private String dataType;
        private String dataNumber;
        private String dataString;
        private String dataTime;
        private String dataContent;

        public int getDataId() {
            return dataId;
        }

        public void setDataId(int dataId) {
            this.dataId = dataId;
        }

        public String getDataIndexName() {
            return dataIndexName;
        }

        public void setDataIndexName(String dataIndexName) {
            this.dataIndexName = dataIndexName;
        }

        public String getDataType() {
            return dataType;
        }

        public void setDataType(String dataType) {
            this.dataType = dataType;
        }

        public String getDataNumber() {
            return dataNumber;
        }

        public void setDataNumber(String dataNumber) {
            this.dataNumber = dataNumber;
        }

        public String getDataString() {
            return dataString;
        }

        public void setDataString(String dataString) {
            this.dataString = dataString;
        }

        public String getDataTime() {
            return dataTime;
        }

        public void setDataTime(String dataTime) {
            this.dataTime = dataTime;
        }

        public String getDataContent() {
            return dataContent;
        }

        public void setDataContent(String dataContent) {
            this.dataContent = dataContent;
        }

        @Override
        public String toString() {
            return "<data>\n" +
                    "  <data_id>" + dataId + "</data_id>\n" +
                    "  <data_index_name>" + dataIndexName + "</data_index_name>\n" +
                    "  <data_type>" + dataType + "</data_type>\n" +
                    "  <data_number>" + dataNumber + "</data_number>\n" +
                    "  <data_string>" + dataString + "</data_string>\n" +
                    "  <data_time>" + dataTime + "</data_time>\n" +
                    "  <data_content>" + dataContent + "</data_content>\n" +
                    "</data>";
        }
    }
}

